/**
 * 作者：陈文斌 on 2019/1/10.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';

class TileSpaceBetween extends StatelessWidget {
  /// 标题
  final Widget title;

  /// 副标题
  final Widget subtitle;

  /// 高度
  final double height;

  /// 背景颜色
  final Color color;

  /// 是否隐藏下划线
  final bool dividerVisible;

  TileSpaceBetween({
    Key key,
    @required this.title,
    this.color,
    this.subtitle,
    this.height = 36,
    this.dividerVisible = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    MainAxisAlignment _mainAxisAlignment = this.subtitle != null
        ? MainAxisAlignment.spaceBetween
        : MainAxisAlignment.start;
    return Container(
      width: MediaQuery.of(context).size.width,
      height: height,
      color: color,
      padding: EdgeInsets.fromLTRB(16, 0, 0, 0),
      child: Column(
        children: <Widget>[
          Expanded(
            child: Row(
              mainAxisAlignment: _mainAxisAlignment,
              children: <Widget>[
                title,
                Padding(
                  padding: EdgeInsets.only(right: 16),
                  child: subtitle ?? Container(),
                )
              ],
            ),
          ),
          Offstage(
            offstage: dividerVisible,
            child: Container(
              height: 1,
              color: AppColors.LineColor,
            ),
          ),
        ],
      ),
    );
  }
}
